#ifndef __SPI_H__
#define __SPI_H__


//-----------------------------------------------------------------------------
//		SPI Read Mode
//-----------------------------------------------------------------------------
#define	SPI_READ_SLOW		0
#define SPI_READ_FAST 		1
#define SPI_READ_DUAL	 	2
#define SPI_READ_QUAD  		3
#define SPI_READ_DUALIO		4
#define SPI_READ_QUADIO		5

#define SPI_READ_MODE		SPI_READ_QUADIO   


//--------------------
// SPI FLASH Vendor
//--------------------
#define SFLASH_VENDOR_MX	0	//MX25L12845(C2 20 18) -- defaut
#define SFLASH_VENDOR_EON	1	//EN25Q128 ID(1C 30 18)
#define SFLASH_VENDOR_WB	2
#define SFLASH_VENDOR_NUM	3	//STM(20 BA 18)

//#define SPIFLASH_EON	 		
//#define SPIFLASH_MX				

extern BYTE SpiFlashVendor;

#define SPI_PAGE	0x04

extern BYTE DMAMODE_RW_FIX_REG;
extern BYTE DMAMODE_RW_INC_REG;
extern BYTE DMAMODE_R_XDATA;
extern BYTE DMAMODE_W_XDATA;
extern BYTE SPICMD_READ;
extern BYTE SPICMD_PROGRAM;
extern BYTE SPICMD_BYTES;

BYTE SPI_SetModeByRegister  ( void );
BYTE SPI_QUADInit(void);
BYTE SPI_QUADInit_Test(void);
void SPI_quadio(void);

void SPI_Init               (void);
void SPI_ReadData2Reg       ( DWORD spiaddr, WORD index, DWORD cnt );
void SPI_ReadData2RegInc    ( DWORD spiaddr, WORD index, DWORD cnt );
void SPI_ReadData2xdata     ( DWORD spiaddr, BYTE *ptr, DWORD cnt );

BYTE SPI_Status				(void);
void SPI_WriteEnable        (void);
void SPI_SectorErase        ( DWORD spiaddr );
void SPI_BlockErase         ( DWORD spiaddr );
void SPI_PageProgram        ( DWORD spiaddr, BYTE *ptr, WORD cnt );


#endif // __SPI_H__

